import gevent


def f(n):
	for i in range(n):
		# 协程遇到了耗时操作就会切换到另一个
		print(gevent.getcurrent(), i)
		gevent.sleep(1)


g1 = gevent.spawn(f, 5)
g2 = gevent.spawn(f, 5)
g3 = gevent.spawn(f, 5)

g1.join()
g2.join()
g3.join()
